# !/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName : HJ43_dfs.py
# @Time     : 2024/3/2 12:28
# @Author   : Robot-Zsj
"""
description: 
"""


def draft_walk(i, j, pos):
    # 这里的maze变量可以读取到
    # 向右
    if j + 1 < n and maze[i][j + 1] == 0:
        if (i, j + 1) not in pos:
            draft_walk(i, j + 1, pos + [(i, j + 1)])
    # 向左
    if j - 1 >= 0 and maze[i][j - 1] == 0:
        if (i, j - 1) not in pos:
            draft_walk(i, j - 1, pos + [(i, j - 1)])
    # 向上
    if i - 1 >= 0 and maze[i - 1][j] == 0:
        if (i - 1, j) not in pos:
            draft_walk(i - 1, j, pos + [(i - 1, j)])
    # 向下
    if i + 1 < m and maze[i + 1][j] == 0:
        if (i + 1, j) not in pos:
            draft_walk(i + 1, j, pos + [(i + 1, j)])
        # 到达出口
    if (i, j) == (m - 1, n - 1):
        for p in pos:
            print(f'({p[0]},{p[1]})')


while True:
    try:
        m, n = list(map(int, input().split()))
        maze = []
        for _ in range(m):
            maze.append(list(map(int, input().split())))

        # def walk(i, j, pos):
        #     if j + 1 < n and maze[i][j + 1] == 0:  # 向右
        #         if (i, j + 1) not in pos:
        #             walk(i, j + 1, pos + [(i, j + 1)])
        #     if j - 1 >= 0 and maze[i][j - 1] == 0:  # 向左
        #         if (i, j - 1) not in pos:
        #             walk(i, j - 1, pos + [(i, j - 1)])
        #     if i + 1 < m and maze[i + 1][j] == 0:  # 向下
        #         if (i + 1, j) not in pos:
        #             walk(i + 1, j, pos + [(i + 1, j)])
        #     if i - 1 >= 0 and maze[i - 1][j] == 0:  # 向上
        #         if (i - 1, j) not in pos:
        #             walk(i - 1, j, pos + [(i - 1, j)])
        #     if (i, j) == (m - 1, n - 1):  # 到达出口
        #         for p in pos:
        #             print('(' + str(p[0]) + ',' + str(p[1]) + ')')

        draft_walk(0, 0, [(0, 0)])
    except:
        break
